*Laura C. Bucci and Joshua M. Jansa
*Stata Code for:
*Who Passes Restrictive Labor Policy? A View from the States
*Journal of Public Policy
*Last Updated 1-20-2020

*first, load in the Analysis Dataset from your working directory.
use "Analysis Dataset for Who Passes Restrictive Labor Policy.dta"

*factor scores for constructing restrictiveness variable, and eigenvalue for table 1
factor rtw noprevwage pwpreempt nr2b plarestrict
*each variable then weighted by factor, summed, and mean subtracted
*we've included the measure for you but this is how to reconstruct it
*using the following code:
*gen rtw_w = 0.75
*gen nopw_w = 0.70
*gen pwpe_w = 0.41
*gen nr2b_w = 0.70
*gen pla_w = 0.31
*gen weightedrtw = rtw*rtw_w
*gen weightednopw = noprevwage*nopw_w
*gen weightedpwpe = pwpreempt*pwpe_w
*gen weightednr2b = nr2b*nr2b_w
*gen weightedpla = plarestrict*pla_w
*gen sum_restrict = weightedrtw+weightednopw+weightedpwpe+weightednr2b+weightedpla
*summarize sum_restrict
*gen restrict = (sum_restrict - 0.8756261)/0.9478801
*chronbach's alpha for table 1
alpha rtw noprevwage pwpreempt nr2b plarestrict

*factor scores for alternative restrictiveness variable
factor rtw noprevwage pwpreempt nr2b plarestrict mwpreempt fmlapreempt
*each variable then weighted by factor, summed, and mean subtracted
*we've included the measure for you but this is how to reconstruct it
*using the following code:
*gen rtw_w_2 = 0.72
*gen nopw_w_2 = 0.67
*gen pwpe_w_2 = 0.46
*gen nr2b_w_2 = 0.66
*gen pla_w_2 = 0.37
*gen mwpe_w_2 = 0.38
*gen fmla_w_2 = 0.33
*gen weightedrtw_2 = rtw*rtw_w_2
*gen weightednopw_2 = noprevwage*nopw_w_2
*gen weightedpwpe_2 = pwpreempt*pwpe_w_2
*gen weightednr2b_2 = nr2b*nr2b_w_2
*gen weightedpla_2 = plarestrict*pla_w_2
*gen weightedmwpe_2 = mwpreempt*mwpe_w_2
*gen weightedfmla_2 = fmlapreempt*fmla_w_2
*gen sum_restrict_2 = weightedrtw_2+weightednopw_2+weightedpwpe_2+weightednr2b_2+weightedpla_2+weightedmwpe_2+weightedfmla_2
*summarize sum_restrict_2
*gen restrict2 = (sum_restrict_2 - 0.8756261)/0.9478801

*regressions for table 3 -- party control and unionization

*model 1
quietly reg restrict i.gop##c.unionall avg_us afp unemp i.st2 i.year
eststo m1
*draw marg eff plot for figure 4 a
qui margins, at(unionall=(6/18)) atmeans saving(margall, replace)
marginsplot, recast(line)
*plots edited for clarity and black and white printing using Stata's Graph Editor features

*model 2
quietly reg restrict i.gop##c.unionpriv avg_us afp unemp i.st2 i.year
eststo m2
*draw marg eff plot for figure 4 b
qui margins, at(unionpriv=(4/12)) atmeans saving(margpub, replace)
marginsplot, recast(line)
*plots edited for clarity and black and white printing using Stata's Graph Editor features


*model 3
quietly reg restrict i.gop##c.unionpub avg_us afp unemp i.st2 i.year
eststo m3
*draw marg eff plot for figure 4 c
qui margins, at(unionpub=(15/51)) atmeans saving(margpub, replace)
marginsplot, recast(line)
*plots edited for clarity and black and white printing using Stata's Graph Editor features


esttab m1 m2 m3 using table3.tex, b(4) se(4) ar2

*regressions for table 4 -- party control and public opinion
*model 1
quietly reg restrict i.gop##c.avg_us unionall afp unemp i.st2 i.year
eststo n1
*draw marg eff plot for figure 6 a
margins, at(avg_us=(.45(.01).66) gop=(1)) atmeans saving(marg1, replace)
marginsplot, recast(line)

*model 2
quietly reg restrict i.gop##c.us_top33 unionall afp unemp i.st2 i.year
eststo n2
*draw marg eff plot for figure 6 d
margins, at(us_top33=(.36(.02).56) gop=(1)) atmeans saving(marg2, replace)
marginsplot, recast(line)

*model 3
quietly reg restrict i.gop##c.us_mid33 unionall afp unemp i.st2 i.year
eststo n3
*draw marg eff plot for figure 6 c
margins, at(us_mid33=(.45(.02).69) gop=(1)) atmeans saving(marg3, replace)
marginsplot, recast(line)

*model 4
quietly reg restrict i.gop##c.us_bot33 unionall afp unemp i.st2 i.year
eststo n4
*draw marg eff plot for figure 6 b
margins, at(us_bot33=(.52(.02).76) gop=(1)) atmeans saving(marg4, replace)
marginsplot, recast(line)

esttab n1 n2 n3 n4 using table4.tex, b(4) se(4) ar2

*regressions for table 5 -- dv = expanded version of labor restrictiveness
*model 1
quietly reg restrict2 i.gop##c.unionall avg_us afp unemp i.st2 i.year
eststo r1

*model 2
quietly reg restrict2 i.gop##c.avg_us unionall afp unemp i.st2 i.year
eststo r2

*model 3
quietly reg restrict2 i.gop##c.us_top33 unionall afp unemp i.st2 i.year
eststo r3

*model 4
quietly reg restrict2 i.gop##c.us_mid33 unionall afp unemp i.st2 i.year
eststo r4

*model 5
quietly reg restrict2 i.gop##c.us_bot33 unionall afp unemp i.st2 i.year
eststo r5

esttab r1 r2 r3 r4 r5 using table5.tex, b(4) se(4) ar2

*correlations for table 6
corr restrict restrict2 unionall unionpub unionpriv massideo govtconserv gop pc unemp afp avg_us us_top33 us_mid33 us_bot33

*regressions for table 7 -- iv = govt conservatism
*model 1
quietly reg restrict c.govtconserv##c.unionall avg_us afp unemp i.st2 i.year
eststo c1

*model 2
quietly reg restrict c.govtconserv##c.avg_us unionall afp unemp i.st2 i.year
eststo c2

*model 3
quietly reg restrict c.govtconserv##c.us_top33 unionall afp unemp i.st2 i.year
eststo c3

*model 4
quietly reg restrict c.govtconserv##c.us_mid33 unionall afp unemp i.st2 i.year
eststo c4

*model 5
quietly reg restrict c.govtconserv##c.us_bot33 unionall afp unemp i.st2 i.year
eststo c5

esttab c1 c2 c3 c4 c5 using table7.tex, b(4) se(4) ar2

*regressions for table 8 -- iv = party control (2=gop, 1=divided, 0=dem)
*model 1
quietly reg restrict i.pc##c.unionall avg_us afp unemp i.st2 i.year
eststo p1

*model 2
quietly reg restrict i.pc##c.avg_us unionall afp unemp i.st2 i.year
eststo p2

*model 3
quietly reg restrict i.pc##c.us_top33 unionall afp unemp i.st2 i.year
eststo p3

*model 4
quietly reg restrict i.pc##c.us_mid33 unionall afp unemp i.st2 i.year
eststo p4

*model 5
quietly reg restrict i.pc##c.us_bot33 unionall afp unemp i.st2 i.year
eststo p5

esttab p1 p2 p3 p4 p5 using table8.tex, b(4) se(4) ar2

*regressions for table 9 -- models of labor opinion
*model 1
quietly reg avg_us massideo c.unionall##c.unionall i.st2 i.year
eststo o1

*model 2
quietly reg avg_us massideo c.unionpriv##c.unionpriv i.st2 i.year
eststo o2

*model 3
quietly reg avg_us massideo c.unionpub##c.unionpub i.st2 i.year
eststo o3

esttab o1 o2 o3 using table9.tex, b(4) se(4) ar2

*mean values displayed in figure 1 map
mean restrict, over(st2)
*these values then used to color map using a blank Google Doc map

*regressions for figure 7 -- models of direct effects
quietly reg restrict gop afp unemp avg_us unionall i.st2 i.year
eststo noint1
quietly reg restrict gop afp unemp avg_us unionpub i.st2 i.year
eststo noint2
quietly reg restrict gop afp unemp avg_us unionpriv i.st2 i.year
eststo noint3
quietly reg restrict gop afp unemp us_top33 unionall i.st2 i.year
eststo noint4
quietly reg restrict gop afp unemp us_mid33 unionall i.st2 i.year
eststo noint5
quietly reg restrict gop afp unemp us_bot33 unionall i.st2 i.year
eststo noint6
quietly reg restrict2 gop afp unemp avg_us unionall i.st2 i.year
eststo noint7
quietly reg restrict2 gop afp unemp avg_us unionpub i.st2 i.year
eststo noint8
quietly reg restrict2 gop afp unemp avg_us unionpriv i.st2 i.year
eststo noint9
quietly reg restrict2 gop afp unemp us_top33 unionall i.st2 i.year
eststo noint10
quietly reg restrict2 gop afp unemp us_mid33 unionall i.st2 i.year
eststo noint11
quietly reg restrict2 gop afp unemp us_bot33 unionall i.st2 i.year
eststo noint12
coefplot noint1 noint7 noint4 noint10 noint5 noint11 noint6 noint12, keep(avg_us us_top33 us_mid33 us_bot33) xline(0)
coefplot noint1 noint7 noint2 noint8 noint3 noint9, keep(unionall unionpub unionpriv) xline(0)

*regressions for figure 8 -- models of individual policies
*subfigure a
quietly reg plarestrict i.gop##c.avg_us unionall afp unemp i.st2 i.year
eststo pla
quietly reg rtw i.gop##c.avg_us unionall afp unemp i.st2 i.year
eststo rtw
quietly reg noprevwage i.gop##c.avg_us unionall afp unemp i.st2 i.year
eststo pw
quietly reg pwpreempt i.gop##c.avg_us unionall afp unemp i.st2 i.year
eststo pwe
quietly reg nr2b i.gop##c.avg_us unionall afp unemp i.st2 i.year
eststo nr2b
quietly reg fmlapreempt i.gop##c.avg_us unionall afp unemp i.st2 i.year
eststo fmla
quietly reg mwpreempt i.gop##c.avg_us unionall afp unemp i.st2 i.year
eststo mw
coefplot pla rtw pw pwe nr2b fmla mw, keep(1.gop 1.gop#c.avg_us) xline(0)

*subfigure b
quietly reg plarestrict i.gop##c.unionall avg_us afp unemp i.st2 i.year
eststo pla0
quietly reg rtw i.gop##c.unionall avg_us afp unemp i.st2 i.year
eststo rtw0
quietly reg noprevwage i.gop##c.unionall avg_us afp unemp i.st2 i.year
eststo pw0
quietly reg pwpreempt i.gop##c.unionall avg_us afp unemp i.st2 i.year
eststo pwe0
quietly reg nr2b i.gop##c.unionall avg_us afp unemp i.st2 i.year
eststo nr2b0
quietly reg fmlapreempt i.gop##c.unionall avg_us afp unemp i.st2 i.year
eststo fmla0
quietly reg mwpreempt i.gop##c.unionall avg_us afp unemp i.st2 i.year
eststo mw0
coefplot pla0 rtw0 pw0 pwe0 nr2b0 fmla0 mw0, keep(1.gop 1.gop#c.unionall) xline(0)


